Release 10.1A: OpenEdge Development:
Progress 4GL Reference


TRUNCATE function

Truncates a decimal expression to a specified number of decimal places, returning a decimal value.

Syntax

TRUNCATE ( expression , decimal-places ) 

expression

A decimal expression that you want to truncate.

decimal-places

A non-negative integer expression that indicates the number of decimal places for a truncated expression.

Example

This procedure doubles each customer’s credit-limit and then truncates that value before rounding it to the nearest $1000:

r-trunc.p
FOR EACH customer:
  FORM cust-num name credit-limit
    new-max LIKE credit-limit LABEL "New Credit limit".
  DISPLAY cust-num name credit-limit.
  credit-limit = TRUNCATE( (credit-limit * 2) / 1000 ,0) * 1000.
  IF credit-limit < 15000 THEN credit-limit = 15000.
  DISPLAY credit-limit @ new-max.
END. 

Note

You can use the TRUNCATE function to treat division as integer division. For example, i = TRUNCATE (x / y, 0).

See also

ROUND function


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095